#ifndef OBJLOADER_H
#define OBJLOADER_H

#include <string>
#include <list>
#include "vertex.h"
#include "vertexnormal.h"
#include "vtexcoord.h"
#include "triangle.h"

//forward declaration
class Triangle;

class OBJObject {

	public:
		OBJObject();
		~OBJObject();

		//member functions
		void loadFile(std::string filename);
		void analyzeFile(std::string filename);
		int getTexFilename(std::string *str);
		void drawObject(void);
		void drawBoundingBox(void);
		int getNumVertices();
		Vertex* getVertex(int index); 
		VertexNormal* getNormal(int index);
		VertexTexCoord* getTexCoord(int index);
		std::list<Triangle*> getTriangleList();
		void setUniqName(std::string uniqName);
		void toggleSelected(void);
		int testBBIntersection(float x, float y, float z);

		//member functions for debugging
		void printVertexList(void);
		void printVertexNormalList(void);
		void printTriangleList(void);
		
		//lists	
		std::list<Vertex*> m_vertexList;
		std::list<VertexNormal*> m_vertexNormalList;
		std::list<VertexTexCoord*> m_vertexTexCoordList;
		std::list<Triangle*> m_triangleList;

		//other variables		
		int m_vertexCounter;
		std::string m_objobjectFilename;
		std::string m_texturefilename;
		std::string m_uniqName;

		float m_maxX, m_minX;
		float m_maxY, m_minY;
		float m_maxZ, m_minZ;

		int frameNum;
		int m_selected;
		
		//MODE_ALL, MODE_NO_VT, MODE_NO_VN,  MODE_ONLY_V 
		int m_mode;

	private:
		int m_vertexCount;
		int m_vertexNormalCount;
		int m_triangleCount;
		int m_texcoordsCount;
};

#endif
